home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / network / chat / ircii-2.8he / ircii-2 / help / WHILE < prev    next >
Encoding:
Text File  |  1993-05-04  |  1.5 KB  |  47 lines

  1. Usage: WHILE <boolean> { <cmd> }
  2.   This will execute the given cmd while the given boolean returns
  3.   true.  The boolean has the same format as for the IF command, except
  4.   that it is re-evaluated at each loop interation.  The same is true
  5.   for cmd.  It is re-evaluated at each loop interation.
  6.   Example (in script format):
  7.     alias repeat
  8.     {
  9.       @ rep = 0;
  10.       while (rep < [$0])
  11.       {
  12.         $1-
  13.         @ rep = rep + 1
  14.       }
  15.       assign -rep
  16.     }
  17.  
  18.   This can be used as follows:
  19.     /repeat 10 /msg bigcheese This repeats 10 times
  20.   The repeat alias breaks down into three parts.
  21.  
  22.     @ rep = 0 
  23.     while (rep < [$0]) {$1-;@ rep = rep + 1}
  24.     assign -rep
  25.  
  26.   The first is to initialize rep to 0 and the last part is to remove
  27.   rep when done.  The first is just like ASSIGN rep 0
  28.   The WHILE portion is described below:
  29.   The boolean for the while loop is (rep < [$0]).
  30.   This is what is then used at each loop interation.  At the
  31.   first iteration this will be ( 0<10 ),  at the next ( 1<10 ), and so on.
  32.   The cmd part of this looks like {$1-;@ rep = rep + 1}
  33.   When the alias is first parsed, the stuff inside {..} is not expanded but
  34.   is simply executed at each loop interation.  It expands to
  35.     'msg bigcheese This repeats 10 times.;@ rep = rep + 1'
  36.   It sends the MSG to BigCheese and then it increments rep by 1.  
  37.   (See HELP @ for more information about this assignment) 
  38.  
  39.   The command part while is exactly like the syntax in IF
  40.   and FOREACH.
  41.  
  42. See Also:
  43.   IF
  44.   FOREACH
  45.   @
  46.   expressions
  47.